package com.totcy.atom.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.totcy.atom.R;
import com.totcy.atom.bean.ImagesBean;
import com.totcy.atom.utils.glide.GlideUtil;
import com.totcy.baselibrary.adapter.BaseLoadMoreAdapter;
import com.totcy.baselibrary.adapter.BaseViewHolder;

import java.util.List;

/**
 * description: xxxiao图片网格适配器
 * author: Totcy
 * date: 2017/11/4 21:41
 * update: 2017/11/4
 */

public class XImageGridAdapter extends BaseLoadMoreAdapter<ImagesBean, BaseViewHolder, BaseViewHolder> {

    public XImageGridAdapter(Context mContext, List<ImagesBean> mDatas) {
        super(mContext, mDatas);
    }

    @Override
    protected BaseViewHolder onCreateItemViewHolder(ViewGroup parent, int viewType) {
        return new BaseViewHolder(getItemView(R.layout.item_image, parent));
    }

    @Override
    protected void onBindItemViewHolder(BaseViewHolder holder, int position) {
        ImagesBean imageBean = mDatas.get(position);
        ImageView ivGirl = holder.getView(R.id.iv_girl);
        ViewGroup.LayoutParams lp = ivGirl.getLayoutParams();
        lp.height = lp.width;
        ivGirl.setLayoutParams(lp);

        GlideUtil.loadImage(mContext,imageBean.getThumbnailUrl(),ivGirl);

        holder.setText(R.id.tv_desc, imageBean.getDescription());
    }

    @Override
    public boolean hasHeader() {
        return false;
    }

    @Override
    protected BaseViewHolder onCreateHeaderViewHolder(ViewGroup parent, int viewType) {
        return null;
    }

    @Override
    protected void onBindHeaderViewHolder(BaseViewHolder holder) {

    }
}
